import {Component, OnInit} from "@angular/core";
import {Page} from "../../../public/util/page";
import {UserService} from "../user.service";
import {Enums, States, UserMinerWorkRecordStates} from '../../../public/setting/enums';
import {SettingUrl} from "../../../public/setting/setting_url";

@Component({
  selector: 'app-user-miner-work-record-list',
  templateUrl: './user-miner-work-record-list.component.html',
  styleUrls: ['./user-miner-work-record-list.component.scss']
})
export class UserMinerWorkRecordListComponent implements OnInit {
  public searchParams: any = {};//搜索参数
  public userMinerWorkRecordList: Page = new Page(); //供应商
  public _loading: boolean = false;
  public routerLinks = SettingUrl.ROUTERLINK;//路由
  public userMinerWorkRecordState = Enums.userMinerWorkRecordState;       // 状态
  public userMinerWorkRecordStates = UserMinerWorkRecordStates; //状态

  constructor(private userService: UserService) {
  }

  ngOnInit() {
    this.queryUserMinerWorkRecordList()
  }

  /**
   * 查询userMinerWorkRecord列表
   * @param curPage 当前页
   */
  queryUserMinerWorkRecordList(curPage?: number) {
    this._loading = true;
    if (curPage) this.userMinerWorkRecordList.curPage = curPage;//当有页码时，查询该页数据
    this.userMinerWorkRecordList.params = {
      account: this.searchParams.account, //account
      curPage: this.userMinerWorkRecordList.curPage, //目标页码
      pageSize: this.userMinerWorkRecordList.pageSize, //每页条数
    };
    this.userService.getUserMinerWorkRecordList(this.userMinerWorkRecordList.params).then((res: Page) => {
      this._loading = false;
      this.userMinerWorkRecordList = res;
    }).catch(err => {
      this._loading = false;
    })
  }

  /**
   * 重置搜索
   */
  resetSearch() {
    this.searchParams = {};
    this.queryUserMinerWorkRecordList(1)
  }
}
